package com.mmall.seckill.controller;

import com.mmall.seckill.common.Result;
import com.mmall.seckill.common.redis.RedisService;
import com.mmall.seckill.common.redis.keyCode.UserKey;
import com.mmall.seckill.rabbitMQ.MQSender;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by megan on 2018/6/15.
 */
@Controller
public class DemoController {

    @Resource
    private RedisService redisService;
    @Resource
    private MQSender mqSender;

    @RequestMapping("/")
    public String home(){
        return "hello";
    }

    @RequestMapping("/redis")
    @ResponseBody
    public String redis(){
        return redisService.set(UserKey.getById,"key1","1");
    }

    @RequestMapping("/mq")
    @ResponseBody
    public Result senMq(){
        mqSender.send("hello word");
        return Result.success();
    }

    @RequestMapping("/mq_topic")
    @ResponseBody
    public Result senMqTopic(){
        mqSender.sendTopic("hello word");
        return Result.success();
    }

    @RequestMapping("/mq_fanout")
    @ResponseBody
    public Result senMqFanout(){
        mqSender.sendFanout("hello word");
        return Result.success();
    }

    @RequestMapping("/mq_header")
    @ResponseBody
    public Result senMqHeader(){
        mqSender.sendHeader("hello word");
        return Result.success();
    }

}
